<cfscript>    
    view = createObject("component", session.rootDir & ".views.layout");
    if( Session.Auth EQ True and (Session.strAuthType EQ Session.MANAGERS or Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR) ){
		view.init("Step 2:  HR - Confirmation Request",
			"/jquery/ui-1.8.5/jquery-ui.min.js,/jquery/plugins/scrollTo/jquery.scrollTo-1.4.2-min.js, /" & session.rootDir & "/static/js/SCF/Step2-HRConfirmRequest.js",
			"/jquery/ui-1.8.5/themes/cupertino/jquery-ui.css","Home",main, "Termination");
    }else{
        view.init("Denied","","","Home","Denied");
    }    
    view.html();
</cfscript>

<cffunction name="main" access="public" output="true" returntype="any">
    <cfparam default="-1" name="url.TermReqID" />
    <cfscript>
        import models.*;
        FormAction = '/' & session.rootDir & '/controller/SubmitHandlerTermination.cfm?SCFStep2=confirm';
        FormActionUpload = '/' & session.rootDir & '/controller/SubmitHandlerTermination.cfm?SCFStep2=upload';
        FileDirectory = '/#session.TerminationDocuments#';
        KronosQueries = CreateObject("component", session.rootDir & ".DatabaseQueries.Kronos");
        TermRequest = entityLoadByPK("TerminationRequests", URL.TermReqID);
        Rosetta = EntityLoad("RosettaStone", TermRequest.getRosettaID());
        FileTypes = EntityLoad("FileTypes", {CategoryID = 2});
        Files = EntityLoad("FileLibrary", {RosettaID = TermRequest.getRosettaID() });
        StepAction = ORMExecuteQuery("FROM StepActions WHERE TermReqID = ? AND StepID = 20", [URL.TermReqID] );
        StepAction = StepAction[1];
        GetTermTypes = KronosQueries.funcGetPersonCodes('TT');
        GetES = KronosQueries.funcGetPersonCodes('ES');
        GetRC = KronosQueries.funcGetReasonCodes('ES');
    </cfscript>
    
    <cfquery name="GetEmpStatus" dbtype="query">
        Select * 
        From GetES
        Where PersonCodeIDNo in (-10133, -10132)
    </cfquery>
    
    <cfquery name="GetESReasonCodes" dbtype="query">
         Select * 
         From GetRC
        Where ReasonCodeIDNo not in (3,5,6,56)
    </cfquery>
    
    
    <cfoutput> 
    <h1 class="title">Step 2:  HR - Confirmation Request</h1>
        <div class="entry">    
            Welcome, #Session.EmpInfo.FirstName# #Session.EmpInfo.LastName#.  
            In this step, you'll verify the termination information submitted by 
            the manager:
            <br /><br />

            <cfform name="frmUpload" method='POST' enctype='multipart/form-data' action="#FormActionUpload#">
            <table width = 100%>
                <tr>
                    <td width =20%>Submitted By:</td>
                    <td>
                        <cfset getEmployee = KronosQueries.funcGetCurrentEmployees( StepAction.getActionByID() ) />
                        <cfset setFullName = '#getEmployee.FirstName# #getEmployee.LastName#' />
                        #getEmployee.FirstName# #getEmployee.LastName#
                        <cfinput type="hidden" name="ManagerName" value="#setFullName#"/>
                    </td>
                </tr>
                <tr>
                    <td width='20%'>Submitted Date/Time:</td>
                    <td>
                        #dateformat(StepAction.getCreationTimeStamp(),'mm/dd/yyyy') & ' ' & timeformat(StepAction.getCreationTimeStamp(),'HH:MM:ss TT')#
                        <cfinput type="hidden" name="DateSubmitted" value="#dateformat(StepAction.getCreationTimeStamp(),'mm/dd/yyyy') & ' ' & timeformat(StepAction.getCreationTimeStamp(),'HH:MM:ss TT')#"/>
                    </td>
                </tr>
                <tr>
                    <td width =20% valign="top">Comments:</td>
                    <td>
                        #StepAction.getNotes()#
                        <cfinput type="hidden" name="ManagerComments" value="#StepAction.getNotes()#"/>
                    </td>
                </tr>
                <tr>
                    <td colspan=2>
                        <HR />
                    </td>
                </tr>
                <tr>
                    <td width =20%>Employee:</td>
                    <td>
                        <cfset getEmployee = KronosQueries.funcGetCurrentEmployees( TermRequest.getRosettaID() ) />
                        <cfset setFullName = '#getEmployee.FirstName# #getEmployee.LastName#' />
                        #getEmployee.FirstName# #getEmployee.LastName#
                        <cfinput type="hidden" name="RosettaID" value="#getEmployee.RosettaID#"/>
                    </td>
                </tr>
                <tr>
                    <td>Termination Type:</td>
                    <td>
                        <cfquery name="GetTermType" dbtype="query">
                            Select PersonCode
                            From GetTermTypes 
                            Where PersonCodeIDNo = #TermRequest.getTermTypeID()#
                        </cfquery>                          
                        #GetTermType.PersonCode#
                    </td>
                </tr>
                <tr>
                    <td>Employee Status:</td>
                    <td>     
                        <cfquery name="GetEmpStatus" dbtype="query">
                            Select PersonCode
                            From GetEmpStatus
                            Where PersonCodeIDNo = <cfqueryparam cfsqltype="cf_sql_integer" value="#TermRequest.getEmpStatusIDNo()#" />
                        </cfquery>                      
                        #GetEmpStatus.PersonCode#
                    </td>
                </tr>
                <tr>
                    <td nowrap="nowrap">Employment Status Reason:</td>
                    <td> 
                        <cfquery name="GetESReasonCodes" dbtype="query">
                            Select ReasonCode
                            From GetESReasonCodes
                            Where ReasonCodeIDNo = #TermRequest.getEmpStatusReasonCode()#
                        </cfquery>                          
                        #GetESReasonCodes.ReasonCode#                         
                    </td>
                </tr>
                <tr>
                    <td>Rehire Eligible?</td>
                    <td>
                        #( TermRequest.getRehireElig() EQ 1 ? "YES" : "NO")#
                    </td>
                </tr>
                <tr>
                    <td valign="top">Effective Termination Date:</td>
                    <td>
                        #dateformat(TermRequest.getTermDate(), 'mm/dd/yyyy')#
                    </td>
                </tr>
                <tr>
                    <td valign="top">HR Termination Date:</td>
                    <td>
                        #dateformat(TermRequest.getSysTermDate(), 'mm/dd/yyyy')#
                    </td>
                </tr>
                <tr>
                    <td valign="top">
                        COBRA Notify Date:
                    </td>
                    <td>
                        #dateformat(TermRequest.getCOBRAEndOfMonth(), 'mm/dd/yyyy')#
                    </td>
                </tr>
                <tr>
                    <td colspan = 2>
                        <fieldset>
                        <legend>File Library</legend>
                        <table width='100%'>
                            <TR>
                                <TD width=5% nowrap="nowrap" valign="top">
                                    File Type:
                                </TD>
                                <TD width="75%">
                                    <cfselect name="FileTypeID" error_message="Please choose a termination document type from the list." >
                                        <option value="-1" >&nbsp;</option>
                                        <Cfloop from="1" to="#ArrayLen(FileTypes)#" index="i">
                                            <option value="#FileTypes[i].getFileTypesID()#" >#FileTypes[i].getName()#</option>
                                        </cfloop>
                                    </cfselect>
                                </TD>
                                <TD>&nbsp;</TD>
                            </TR>
                            <TR>
                                <TD width='5%' nowrap="nowrap" valign="top">File:</TD>
                                <TD width="75%">
                                    <cfinput type="file" name="FileUpload" error_message="Please specify the file to upload." style="width:100%">                                      
                                </TD>
                                <TD align="right" valign="bottom">
                                    <cfinput name="Upload" type="button" value="Upload"> 
                                </TD>
                            </TR>   
                            <tr>
                                <td colspan=3>
                                    <HR />
                                </td>
                            </tr>   
                            <TR>
                                <TD colspan=3>
                                    <table width="100%">
                                        <TR>
                                            <TD rowspan="4" colspan=3 valign="top">
                                            <cfif ArrayLen( Files ) EQ 0>
                                                <span class="failed" style="font-size:90%">No existing files associated with this termination request</span>
                                            <cfelse>
                                                <Table width=100%>
                                                    <TR>
                                                        <TD><strong>File Type</strong></TD>
                                                        <TD width=1%>&nbsp;</TD>
                                                        <TD><strong>Date Submitted</strong></TD>
                                                        <TD width=1%>&nbsp;</TD>
                                                        <TD><strong>Submitted By</strong></TD>
                                                        <TD width=1%>&nbsp;</TD>
                                                        <TD><strong>File Name</strong></TD>
                                                    </TR>
                                                <cfloop from="1" to="#ArrayLen(Files)#" index="i">                                                    
                                                    <TR>
                                                        <cfset FileType = EntityLoad("FileTypes", {FileTypesID = Files[i].getFileTypeID()}) />
                                                        <TD nowrap="nowrap">#FileType[1].getName()#</TD>
                                                        <TD>&nbsp;</TD>
                                                        <TD nowrap="nowrap">#dateformat(Files[i].getDateLoaded(), 'm/d/yyyy')#</TD>
                                                        <TD>&nbsp;</TD>
                                                        <TD nowrap="nowrap">
                                                            <cfset LoadedBy = KronosQueries.funcGetCurrentEmployees( Files[i].getLoadedBy() ) />
                                                            #LoadedBy.FirstName# #LoadedBy.LastName#
                                                        </TD>
                                                        <TD>&nbsp;</TD>
                                                        <TD nowrap="nowrap">                                        
                                                            <a href="/#session.mediaDir#/documents/termination/#Files[i].getFileName()#" target="_blank">#Files[i].getFileName()#</a>
                                                        </TD>
                                                    </TR>
                                                </cfloop>
                                                </Table>
                                            </cfif>     
                                            </TD>
                                        </TR>
                                    </table>
                                </TD>
                            </TR>                       
                        </table>    
                        </fieldset>                 
                    </td>
                </tr>
            </table>
            
            <cfinput type="hidden" name="TermReqID" value="#URL.TermReqID#" />
            
            </cfform>
            
            <cfform id="frmFinal" name="frmFinal" method='POST' enctype='multipart/form-data' action="#FormAction#">
            <table width="100%">
                <tr>
                    <td width="100%">
                        Final Comments:
                    </td>
                </tr> 
                <tr>
                    <td align="right" width="100%">
                        <cftextarea name="Comments" value="#StepAction.getNotes()#" style="width:100%"/>
                    </td>
                </tr>  
                <tr>
                    <td  align="right">
                        <cfinput type="hidden" name="TermReqID" value="#URL.TermReqID#" />
                        <cfinput type="hidden" name="StepID" value="#StepAction.getStepActionsID()#" />
                        <cfinput type="hidden" name="FormAction" value="#FormAction#">
                        <cfinput type="hidden" name="FormActionUpload" value="#FormActionUpload#">
                        <cfinput type="button" name="Back" value="<< Back" tabindex="75" >
                        <cfinput type="button" name="Finish" value="Finish (Terminate)" tabindex="80">
                    </td>
                </tr>  
            </table>
            </cfform>
        </div>    
    </cfoutput>
    
</cffunction>